<template>
  <div class="content-block">
    <div class="info-head">{{ title }}</div>
    <div class="info-content">
      <v-chart :option="chartOption" style="width:100%;height:300px;"></v-chart>
    </div>
  </div>
</template>

<script>
export default {
  name: 'bar-chart',
  props: ['title', 'unit'],
  computed: {
    chartOption () {
      // TODO
      const lines = ['造纸', '煤炭', '化学', '炼焦', '其他']
      return {
        grid: {
          left: '15%',
          right: '25%',
          top: '10%',
          bottom: '15%'
        },
        xAxis: {
          type: 'value',
          name: this.unit,
          axisLine: {
            show: true
          }
        },
        yAxis: {
          type: 'category',
          data: lines
        },
        series: [
          {
            type: 'bar',
            data: lines.map(v => ({
              name: v,
              value: Math.round(Math.random() * 99 + 1)
            })).sort((a, b) => a.value - b.value)
          }
        ]
      }
    }
  }
}
</script>

<style scoped>

</style>
